<?php
	if( defined('SAE_MYSQL_HOST_M') )
		include ("DBclass.php");
	else
		include ("DBclass2.php");
	
	$db = new DB;
	global $db;
	
	function sendEmail( $email , $title , $content )
	{
		$mail = new SaeMail();
		$mail->quickSend( $email , $title , $content ,'scuttransaction@qq.com' , '3.141592653' );
	}
	
	function update($name,$key,$value,$table="userInfo")
	{
		global $db;
		$query = "update $table set $key = '$value' where name = '$name'";
		return $db->runSql($query);
	}
	
	function select($key,$value,$table="userInfo")
	{
		global $db;
		$query = "select * from $table where $key = '$value'";
		$db->getData($query);
		return $db->res;
	}
	
	function selectone($key,$value,$table="userInfo")
	{
		global $db;
		$query = "select * from $table where $key = '$value' limit 0,1";
		$db->getData($query);
		if( $db->res )
			return $db->res[0];
		else
			return false;
	}
	
	function selects($condition,$table="userInfo")
	{
		global $db;
		$query = "select * from $table where ".$condition;
		$db->getData($query);
		return $db->res;
	}
	
	function delete($key,$value,$table="userInfo")
	{
		global $db;
		$query = "delete from $table where $key = '$value'";
		return $db->runSql($query);
	}

	function runSql($query)
	{
		global $db;
		return $db -> runSql($query);
	}
	
	function showError()
	{
		global $db;
		echo $db->error;
	}
	
	function listFile($path = '.') {
		$fileList = null;
		$current_dir = opendir($path);
		if( $current_dir == null ) return ;
		while(($file = readdir($current_dir)) !== false)
		{
			if($file == '.' || $file == '..')
			{
				continue;
			}
			else if(is_dir($sub_dir))
			{
				// 文件夹则不处理
			}
			else
			{
				$fileList[count($fileList)] = $path . DIRECTORY_SEPARATOR . $file ;
			}
		}
		return $fileList;
	}
	
	function isArray( $a )
	{
		return isset($a) && is_array($a);
	}
?>